/** tencent-v1.0.0 MIT License By hubo e-mail:1151570866@qq.com*/
/**
 * Created by netperson on 18/10/20.
 */
var layer;
layui.use('layer', function(){
    layer = layui.layer;
});
function layerClose()
{
    layer.closeAll();
}
function layerParentClose()
{
    parent.layer.closeAll();
}
function layerAlert(_content,_fun)
{
    if(!_fun)_fun=function(){};
    layer.open({
        type: 0,
        skin: 'layui-layer-molv',
        title: '提示',
        content:_content,
        btnAlign: 'r',
        btn1:function(index,idno){
            if(_fun!=null){
                _fun();
                layer.close(index);
            }
            else
            {
                layer.close(index);
            }
        }
    });
}
function layerWindow(_title,_url,_width,_height,_cancel)
{
    if(!_title)_title="操作";
    if(_cancel==null)_cancel=function(){};
    layer.open({
        type: 2,
        title: _title,
        shadeClose: true,
        shade: 0.6,
        area: [_width, _height],
        content: _url,
        cancel:_cancel
    });
}
function layerConfirm(_title,_yesfun,_nofun)
{
    //询问框
    if(!_yesfun)_yesfun=function () {

    }
    if(!_nofun)_nofun=function () {

    }
    layer.confirm(_title,
        {
            skin: 'layui-layer-molv',
            btn: ['是','否'] //按钮
        }, function(){
            _yesfun();
        }, function(){
            _nofun();
        });
}
function layerPager(_page,_size,_sum,_obj,_callbackfunction)
{
    _page=parseInt(_page);
    _size=parseInt(_size);
    _sum=parseInt(_sum);
    //依赖于commjslib.js,layui
    var pageArray=splitPagerArray(_page,_size,_sum);
    var html='<div class="layui-btn-group">';
    html+='<button class="layui-btn layui-btn-primary layui-btn-small">总数'+pageArray[5]+'</button>';
    html+='<button class="layui-btn layui-btn-primary layui-btn-small">第'+_page+'/'+pageArray[4]+'页</button>';
    html+='<button class="layui-btn layui-btn-primary layui-btn-small" onclick="'+_callbackfunction+'(\''+pageArray[0]+'\');">首页</button>';
    html+='<button class="layui-btn layui-btn-primary layui-btn-small" onclick="'+_callbackfunction+'(\''+pageArray[1]+'\');">上一页</button>';
    html+='<button class="layui-btn layui-btn-primary layui-btn-small" onclick="'+_callbackfunction+'(\''+pageArray[2]+'\');">下一页</button>';
    html+='<button class="layui-btn layui-btn-primary layui-btn-small" onclick="'+_callbackfunction+'(\''+pageArray[3]+'\');">尾页</button>';
    html+='</div>';
    $("#"+_obj).html(html);
}